﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

namespace DataAnalyseTool.Utilities
{
  public class XmlOpts
  {
    protected static readonly log4net.ILog log =
    log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    public static XmlNodeList GetNodeListFromXML(string path, string rootItem)
    {
      XmlDocument xml = null;
      XmlNodeList lists = null;

      if (WinSysOpts.isFileExist(path))
      {
        try
        {
          xml = new XmlDocument();
          xml.Load(path);
          XmlNode root = xml.SelectSingleNode(rootItem);
          lists = root.ChildNodes;
        }
        catch (Exception ex)
        {
          log.Error("读取路径：【" + path + "】的时候发生了异常，异常信息是： " + ex.Message);
        }
      }

      return lists;
    }
  }
}